package com.my.servlet;

import com.sun.net.httpserver.HttpsServer;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/*  实现servlet
    1、创建普通java类
    2、实现Servlet的规范，继承HttpServlet类
    3、重写service方法，用来处理请求
    4、设置注解，指定访问的路径
* */
//@WebServlet("/ser01")
//@WebServlet(name = "Servlet01",value = "/ser01")
//@WebServlet(name = "Servlet01",value = {"/ser01","/ser001"})
@WebServlet(name = "Servlet01",urlPatterns = {"/ser01","/ser001"})

public class Servlet01 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("hello servlet");
        //通过流输出数据到浏览器
        resp.getWriter().write("hello servlet");
    }
}
